<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function fn() {
      var date = new Date()
      var h  =  date.getHours()
      h = h >  10 ? h : '0' + h

      var m = date.getMinutes()
      m = m >  10 ? m : '0' + m

      var s = date.getSeconds()
      s = s >  10 ? s : '0' + s

      var str = h + ':' + m + ':' + s

      console.log(str)
    }

    fn()
  </script>
</body>
</html>